<div class="dux-page-header uk-clearfix">
    <div class="page-title">
        <a class="uk-button uk-button-primary" href="{url('index')}"> 字段列表</a>
    </div>
    <div class="page-action">
        <a class="uk-button uk-button-danger" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
    </div>
</div>

<div class="uk-margin-top">
    <div class="uk-card uk-card-small uk-card-default dux-panel">
        <div class="uk-card-header">{$assignName}字段</div>
        <div class="uk-card-body">
            <form class="dux-form uk-form  uk-form-horizontal  " data-dux="form-bind" method="post">
                <fieldset>
                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段名称</label>
                        <div class="uk-form-controls">
                            <input type="text" name="name" value="{$info.name}" placeholder="请输入字段名称" required>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段标识</label>
                        <div class="uk-form-controls">
                            <input type="text" name="label" value="{$info.label}" placeholder="表单内唯一不重复标识,英文或者数字且英文开头" pattern="^[a-z]\w+$" required>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段类型</label>
                        <div class="uk-form-controls">
                            <select name="type" id="type">
                                <!--loop{$type as $key => $vo}-->
                                <option value="{$key}" <!--if{strtolower($key) == $info['type']}--> selected <!--{/if}--> >{$vo}({$key})</option>
                                <!--{/loop}-->
                            </select>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段提示</label>
                        <div class="uk-form-controls">
                            <input type="text" name="tip" value="{$info.tip}" placeholder="字段输入提示" >
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">必要字段</label>
                        <?php if(!isset($info['must'])) $info[ 'must']=1 ; ?>
                        <div class="uk-form-controls uk-form-controls-text">
                            <div class="uk-grid">
                                <label>
                                    <!--if{$info['must']}-->
                                    <input name="must" value="1" checked="checked" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="must" value="1" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    必须
                                </label>

                                <label>
                                    <!--if{!$info['must']}-->
                                    <input name="must" checked="checked" value="0" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="must" value="0" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    非必须
                                </label></div>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段配置</label>
                        <div class="uk-form-controls">
                            <textarea name="config" id="config" disabled>{$info.config}</textarea>
                            <div class="uk-form-help" id="help">该字段暂不支持配置</div>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">默认值</label>
                        <div class="uk-form-controls">
                            <input type="text" name="default" value="{$info.default}" placeholder="字段输入为空时的默认值"
                                   >
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">字段顺序</label>
                        <div class="uk-form-controls">
                            <input type="text" name="sort" value="{$info.sort}" placeholder="字段显示顺序小->大" >
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">列表显示</label>
                        <div class="uk-form-controls uk-form-controls-text">
                            <div class="uk-grid">
                                <label>
                                    <!--if{$info['show']}-->
                                    <input name="show" value="1" checked="checked" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="show" value="1" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    显示
                                </label>

                                <label>
                                    <!--if{!$info['show']}-->
                                    <input name="show" checked="checked" value="0" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="show" value="0" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    隐藏
                                </label></div>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <label class=" uk-form-label">前台提交</label>
                        <div class="uk-form-controls uk-form-controls-text">
                            <div class="uk-grid">
                                <label>
                                    <!--if{$info['submit']}-->
                                    <input name="submit" value="1" checked="checked" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="submit" value="1" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    支持
                                </label>

                                <label>
                                    <!--if{!$info['submit']}-->
                                    <input name="submit" checked="checked" value="0" type="radio"  class="uk-radio" >
                                    <!--{else}-->
                                    <input name="submit" value="0" type="radio"  class="uk-radio" >
                                    <!--{/if}-->
                                    不支持
                                </label></div>
                        </div>
                    </div>

                    <div class="uk-form-group">
                        <div class="uk-form-controls">
                            <input type="hidden" name="form_id" value="{$formId}">
                            <input type="hidden" name="field_id" value="{$info.field_id}">
                            <button class="uk-button uk-button-primary" type="submit" disabled>保存</button>
                        </div>
                    </div>

                </fieldset>
            </form>
        </div>
    </div>
</div>
<script>
    Do('base', function () {
        var help = function() {
            app.ajax({
                url : "{url('help')}",
                type : 'post',
                data : {type : $('#type').val()},
                success : function($info) {
                    if($info == '') {
                        $('#config').attr('disabled', true);
                        $('#help').text('该字段不支持配置');
                    }else {
                        $('#config').attr('disabled', false);
                        $('#help').text($info);
                    }
                }

            });
        };
        help();
        $('#type').change(function() {
            help();
        });

    });
</script>